//商品相关接口
import request from "@/utils/request.ts";
import type { skuListResponseData } from "./type";

// 品牌接口

enum API {
  // 商品SKU接口
  // GET
  spuImageList = "/admin/product/spuImageList",
  // spu对应图片

  // GET
  spuSaleAttrList = "/admin/product/spuSaleAttrList",
  // spu对应销售属性

  // POST
  saveSkuInfo = "/admin/product/saveSkuInfo",
  // 添加新的SKU

  // GET
  findBySpuId = "/admin/product/findBySpuId",
  // 根据spu查询sku列表

  // GET
  getskulist = "/admin/product/list",
  // 获取sku分页数据

  // GET
  onsale = "/admin/product/onSale",
  cancelsale = "/admin/product/cancelSale",
  // sku上下架处理

  // DELETE
  deletesku = "/admin/product/deleteSku",
  // 删除sku

  // GET
  getSkuInfo = "/admin/product/getSkuInfo",
  //获取指定sku信息
}

export const spuImageList = (spuId: number) =>
  request.get<any, any>(API.spuImageList + `/${spuId}`);

export const reqspuSaleAttrList = (spuId: number) =>
  request.get<any, any>(API.spuSaleAttrList + `/${spuId}`);

export const reqsaveSkuInfo = (data: any) =>
  request.post<any, any>(API.saveSkuInfo, data);

export const reqfindBySpuId = (spuId: number) =>
  request.get<any, any>(API.findBySpuId + `/${spuId}`);

export const reqgetskulist = (page: number, limit: number) =>
  request.get<any, skuListResponseData>(API.getskulist + `/${page}/${limit}`);

export const reqonsale = (spuId: number) =>
  request.get<any, any>(API.onsale + `/${spuId}`);

export const reqcancelsale = (spuId: number) =>
  request.get<any, any>(API.cancelsale + `/${spuId}`);

export const reqdeletesku = (spuId: number) =>
  request.delete<any, any>(API.deletesku + `/${spuId}`);

export const reqgetSkuInfo = (spuId: number) =>
  request.get<any, any>(API.getSkuInfo + `/${spuId}`);
